package com.movie.mybatis.web;

import com.movie.mybatis.service.impl.MovieRootServlet;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;

@WebServlet({"/root/list", "/root/detail", "/root/delete", "/root/save", "/root/modify"})
public class MovieRootWebServlet extends HttpServlet {
    private final MovieRootServlet movieRootServlet = new MovieRootServlet();
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String servletPath = request.getServletPath();

        if ("/root/list".equals(servletPath)) {
            movieRootServlet.doList(request, response);
        } else if ("/root/detail".equals(servletPath)) {
            movieRootServlet.doDetail(request, response);
        } else if ("/root/delete".equals(servletPath)) {
            movieRootServlet.doDel(request, response);
        }  else if ("/root/modify".equals(servletPath)) {
            movieRootServlet.doModify(request, response);
        }else if ("/root/save".equals(servletPath)) {
            movieRootServlet.doMovieSave(request, response);
        }
    }
}
